package com.puman.watchtrade.util;
import org.achartengine.ChartFactory;
import org.achartengine.model.MultipleCategorySeries;
import org.achartengine.renderer.DefaultRenderer;
import org.achartengine.renderer.SimpleSeriesRenderer;

import android.content.Context;
import android.view.View;

import com.puman.watchtrade.MainActivity;
import com.puman.watchtrade.R;
   
public class CircleChart { 
    public View execute(Context context,double first,double second,double three) { 
        int[] colors = new int[] {MainActivity.getInstant().getResources().getColor(R.color.grap1), 
        		MainActivity.getInstant().getResources().getColor(R.color.grap2), 
        		MainActivity.getInstant().getResources().getColor(R.color.grap3) }; 
        
        DefaultRenderer renderer = buildCategoryRenderer(colors); 

        String [] titles = new String [3];
        titles[0] = "֪�Ŀ�";
        titles[1] = "���Ŀ�";
        titles[2] = "���Ŀ�";
        double [] valus = new double [3];
        valus[0] = first;
        valus[1] = second;
        valus[2] = three;
       
        MultipleCategorySeries  categorySeries = new MultipleCategorySeries ("��Ա����"); 
        categorySeries.add(titles, valus);   
        return ChartFactory 
                .getDoughnutChartView(context, categorySeries, renderer); 
        
    } 
   
    protected DefaultRenderer buildCategoryRenderer(int[] colors) { 
        DefaultRenderer renderer = new DefaultRenderer(); 

        for (int color : colors) { 
            SimpleSeriesRenderer r = new SimpleSeriesRenderer(); 
            r.setColor(color); 
            renderer.addSeriesRenderer(r);   
        } 
        //��ʾ��ǩ 
        renderer.setShowLabels(false); 
        renderer.setStartAngle(180);
        renderer.setShowGrid(true);
        
        //Log.i("liuwenjie","ttt"+);

        return renderer; 
    } 
    
    
}